import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:geolocator/geolocator.dart';

abstract class FMBasePageWidget extends StatefulWidget {
  const FMBasePageWidget({super.key});
}

abstract class FMBasePageState<T extends FMBasePageWidget> extends State<T> {

  @override
  void initState() {
    super.initState();
    _getLocation();
  }

  Future<void> _getLocation() async {
    LocationPermission permission = await Geolocator.checkPermission();

    if (permission == LocationPermission.whileInUse || permission == LocationPermission.always) {
      // 获取当前位置
      Position position = await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);

      onLocationUpdated(position);
    } else {
      print('Location permission denied');
    }
  }


  void onLocationUpdated(Position position);

  @override
  void dispose() {
    super.dispose();
  }

}
